package com.huonan.jb.tools.kafka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class MyKafkaProducer {

    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;
    private   static  int count = 0;

//    @KafkaListener(id="my-listener-id",groupId  = "my-listener", topics = "kktt", concurrency = "1")
    public void listen() {
        // 处理消息
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
//        kafkaTemplate.send("kktt", "0"+count,"d-"+count);
        count++;
    }
}